group:
  {{ nexus_group }}:
    exists: true

user:
  {{ nexus_user }}:
    exists: true
    groups:
      - {{ nexus_group }}

file:
  {{ nexus_data_path }}:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
    filetype: directory
  {{ nexus_installation_path }}:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
    filetype: directory
  {{ nexus_log_path }}:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
    filetype: directory
  {{ nexus_tmp_path }}:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
    filetype: directory
  /lib/systemd/system/nexus.service:
    exists: true
  {{ nexus_data_path }}/blobs/blob-mvn:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-docker:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-npm:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-nuget:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-pypi:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-raw:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  {{ nexus_data_path }}/blobs/blob-composer:
    owner: {{ nexus_user }}
    group: {{ nexus_group }}
    exists: true
  /opt/nexus/datadog/dd-java-agent-0.73.0.jar:
    exists: true
  /opt/nexus/bin/nexus.vmoptions:
    exists: true
    contains:
      - -javaagent:/opt/nexus/datadog/dd-java-agent-0.73.0.jar
      - -Ddd.profiling.enabled=true
      - -Ddd.logs.injection=true
      - -Ddd.service=sample
      - -Ddd.env=molecule

port:
  tcp:{{ nexus_port }}:
    listening: true
  tcp:{{ nexus_docker_proxy_port }}:
    listening: true
  tcp:{{ nexus_docker_hosted_port }}:
    listening: true
  tcp:{{ nexus_docker_group_port }}:
    listening: true
  tcp:{{ nexus_jmx_port }}:
    listening: true

http:
  #User
{% for user in nexus_users %}
  http://localhost:{{ nexus_port }}/service/rest/v1/security/users:
    status: 200
    body:
    - "{{ user.username }}"
    username: admin
    password: "{{ nexus_admin_password }}"
{% endfor %}
  #Realm
{% for realm in nexus_realms %}
  http://localhost:{{ nexus_port }}/service/rest/v1/security/realms/available:
    status: 200
    body:
    - "{{ realm.name }}"
    username: admin
    password: "{{ nexus_admin_password }}"
{% endfor %}
  #LDAP
{% for ldap_config in nexus_ldap_configs %}
  http://localhost:{{ nexus_port }}/service/rest/v1/security/ldap/{{ ldap_config.name }}:
    status: 200
    username: admin
    password: "{{ nexus_admin_password }}"
{% endfor %}

{% for role in nexus_roles %}
  #Role
  http://localhost:{{ nexus_port }}/service/rest/v1/security/roles/{{ role.id }}:
    status: 200
    username: admin
    password: "{{ nexus_admin_password }}"
{% endfor %}

  #Repositories
  http://localhost:{{ nexus_port }}/service/rest/v1/repositories:
    status: 200
    username: admin
    password: "{{ nexus_admin_password }}"
    body:
{% for repository_type in nexus_repositories_maven.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
{% for repository_type in nexus_repositories_docker.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
{% for repository_type in nexus_repositories_npm.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
{% for repository_type in nexus_repositories_nuget.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
{% for repository_type in nexus_repositories_pypi.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
{% for repository_type in nexus_repositories_raw.values() %}
{% for repository in repository_type %}
    - "{{ repository.name }}"
{% endfor %}
{% endfor %}
# Composer repos depends on a plugin therefore we cannot iterate freely in its properties.
{% for repository in nexus_repositories_composer.proxy %}
    - "{{repository.name }}"
{% endfor %}
{% for repository in nexus_repositories_composer.hosted %}
    - "{{repository.name }}"
{% endfor %}
{% for repository in nexus_repositories_composer.group %}
    - "{{repository.name }}"
{% endfor %}

service:
  nexus:
    enabled: true
    running: true
